home *** CD-ROM | disk | FTP | other *** search
- Path: news.luc.edu!user
- From: VArase@varase.it.luc.edu (Verne Arase)
- Newsgroups: comp.lang.c,comp.unix.programmer
- Subject: Re: Q: '\n' character
- Date: Thu, 04 Apr 1996 21:30:55 -0600
- Organization: LUMC
- Message-ID: <AD89F00F96681642B@mcdiala09.it.luc.edu>
- References: <31616F63.481D@lava.weeg.uiowa.edu>
- NNTP-Posting-Host: 147.126.240.109
-
- In article <31616F63.481D@lava.weeg.uiowa.edu>,
- Artur Wojdat <awojdat@lava.weeg.uiowa.edu> wrote:
-
- > Is there a function or some sort of way that I could remove '\n'
- >charecter form the end of the string. I'm reading from two files, want to
-
- >form one line of text and then have it printed out to stdout. I use fgets
- to
- >read from the file and I noticed that it appends newline char at the end.
-
- Try:
-
- int len;
- char *endptr;
-
- ...
-
- if ((len=strlen(buf))>0) {
- endptr=buf+len;
- if (*--endptr=='\n')
- *endptr=0;
- }
-
-
- ---
- The above are my own opinions, and not those of my employer.
-